<%@ page import="com.goal98.team.Constants" %>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main"/>
    <title><g:message code="team.show" default="Show Team"/>--${teamInstance}</title>
  </head>
  <body>
    <div class="nav">
    %{--<span class="menuButton"><a class="home" href="${createLinkTo(dir: '')}"><g:message code="home" default="Home" /></a></span>--}%
      <span class="menuButton"><g:link class="list" action="list"><g:message code="team.list" default="Team List"/></g:link></span>
      <span class="menuButton"><g:link class="list" action="search"><g:message code="team.search" default="Team Search"/></g:link></span>
      <g:ifAnyGranted role="${Constants.ROLE_ADMIN}">
        <span class="menuButton"><g:link class="create" action="create"><g:message code="team.new" default="New Team"/></g:link></span>
      </g:ifAnyGranted>
    </div>
    <div class="body">
      <h1><g:message code="team.show" default="Show Team"/></h1>
      <g:if test="${flash.message}">
        <div class="message"><g:message code="${flash.message}" args="${flash.args}" default="${flash.defaultMessage}"/></div>
      </g:if>
      <g:form>
        <g:hiddenField name="id" value="${teamInstance?.id}"/>
        <div class="dialog">
          <table>
            <tbody>

              <tr class="prop">
                <td valign="top" class="name"><g:message code="team.id" default="Id"/>:</td>

                <td valign="top" class="value">${fieldValue(bean: teamInstance, field: "id")}</td>

              </tr>

              <tr class="prop">
                <td valign="top" class="name"><g:message code="team.dateCreated" default="Date Created"/>:</td>

                <td valign="top" class="value"><g:formatDate date="${teamInstance?.dateCreated}"/></td>

              </tr>

              <tr class="prop">
                <td valign="top" class="name"><g:message code="team.lastUpdated" default="Last Updated"/>:</td>

                <td valign="top" class="value"><g:formatDate date="${teamInstance?.lastUpdated}"/></td>

              </tr>

              <tr class="prop">
                <td valign="top" class="name"><g:message code="team.members" default="Members"/>:</td>

                <td valign="top" style="text-align: left;" class="value">
                  <ul>
                    <g:each in="${teamInstance?.members}" var="personInstance">
                      <li><g:link controller="person" action="show" id="${personInstance.id}">${personInstance.encodeAsHTML()}</g:link></li>
                    </g:each>
                  </ul>
                  <g:link controller="person" params="['team.id':teamInstance?.id]" action="create"><g:message code="player.create" default="Add Player"/></g:link>
                </td>

              </tr>

              <tr class="prop">
                <td valign="top" class="name"><g:message code="team.name" default="Name"/>:</td>

                <td valign="top" class="value">${fieldValue(bean: teamInstance, field: "name")}</td>

              </tr>

              <tr class="prop">
                <td valign="top" class="name"><g:message code="team.teamAdmins" default="Team Admins"/>:</td>

                <td valign="top" class="value">${fieldValue(bean: teamInstance, field: "teamAdmins")}</td>

              </tr>

            </tbody>
          </table>
        </div>
        <div class="buttons">
          <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'button.edit', 'default': 'Edit')}"/></span>
          <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'button.delete', 'default': 'Delete')}" onclick="return confirm('${message(code: 'delete.confirm', 'default': 'Are you sure?')}');"/></span>
        </div>
      </g:form>
    </div>
  </body>
</html>
